/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package main.java.cn.webrx;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.PrintWriter;

/**
 * <p>Project: jse2204 - File1
 * <p>Powered by webrx On 2022-09-21 15:32:29
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class File1 {
    public static void main(String[] args) throws Exception{
        //建立文件 空文件
        File f1 = new File("a.txt");
        f1.createNewFile();

        //建立文件并写入内容
        PrintWriter out = new PrintWriter("b.txt");
        out.write("hello 中文\n");
        out.printf("%tF %<tT%n",System.currentTimeMillis());
        out.flush();

        //字节流写入文件
        FileOutputStream fos = new FileOutputStream("c.txt",true);
        for (int i = 0; i < 10; i++) {
            fos.write("97 - hello 文件写入\r\n".getBytes());
        }
        fos.close();

        //字符流
        FileWriter fw = new FileWriter("d.txt");
        fw.write("hello程序设计");
        fw.close();
    }
}
